package main

import (
	"fmt"
	"sync"
	"time"
)

type Singleton struct {
	Name string
}

var instance *Singleton
var once sync.Once

func NewInstance() *Singleton {
	once.Do(func() {
		time.Sleep(1 * time.Second)
		instance = &Singleton{
			Name: "Singleton",
		}
	})
	return instance
}

func main() {
	for i := 0; i < 100; i++ {
		go func() {
			i1 := NewInstance()
			fmt.Printf("%p\n", i1)
		}()
	}
	time.Sleep(2 * time.Second)
}
